@use 'sass:map';
@import 'mixins/form';
@import 'mixins/date-input';
@import 'mixins/overwrite';

@include b(date-picker) {
  @include component-in-form('#{&}') {
    max-width: 100%;
  }

  @include component-date-input;

  @include e(popup) {
    position: fixed;
    overflow: auto hidden;
    white-space: nowrap;
    background-color: var(--#{$rd-prefix}background-color);
    border-radius: var(--#{$rd-prefix}border-radius);
    box-shadow: var(--#{$rd-prefix}shadow-popup);
  }

  @include e(header) {
    display: flex;
    align-items: center;
    height: 41px;
    padding: 0 8px;
    border-bottom: 1px solid var(--#{$rd-prefix}color-divider);
  }

  @include e(header-content) {
    margin: 0 auto;
  }

  @include e(header-button) {
    @include utils-button;

    width: 24px;
    height: 100%;
    padding: 0;
    margin: 0;
    color: var(--#{$rd-prefix}color-icon-decorator);
    background-color: transparent;
    border: none;
    transition: color var(--#{$rd-prefix}animation-duration-base) linear;

    &:hover,
    &:focus {
      color: var(--#{$rd-prefix}color-primary-lighter);
    }

    &:active {
      color: var(--#{$rd-prefix}color-primary-darker);
    }
  }

  @include e(panel) {
    display: inline-block;
    vertical-align: top;

    & + .#{$rd-prefix}time-picker__panel {
      border-left: 1px solid var(--#{$rd-prefix}color-divider);
    }
  }

  @include e(content) {
    width: calc(7 * 36px);
    margin: 4px;
    table-layout: fixed;
    border-collapse: collapse;

    tr {
      height: 32px;
    }
  }

  @include e(cell) {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 26px;
    cursor: pointer;

    &:not(.is-current-selected):not(.is-another-selected):not(.is-hover):not(.is-between):not(.is-between-hover):hover {
      background-color: var(--#{$rd-prefix}background-color-hover);
    }

    @include when(disabled) {
      color: var(--#{$rd-prefix}color-disabled);
      pointer-events: none;
      background-color: var(--#{$rd-prefix}background-color-disabled);
    }

    @include m(out-month) {
      color: var(--#{$rd-prefix}color-disabled);
    }

    @include m(today) {
      &::after {
        position: absolute;
        top: 2px;
        right: 2px;
        bottom: 2px;
        left: 2px;
        content: '';
        border: 1px solid var(--#{$rd-prefix}color-primary);
      }
    }

    @include when(current-selected) {
      color: map.get($rd-colors, 'white');
      background-color: var(--#{$rd-prefix}color-primary);
    }

    @include when(another-selected) {
      color: map.get($rd-colors, 'white');
      background-color: var(--#{$rd-prefix}color-primary-lighter);
    }

    @include when(hover) {
      color: map.get($rd-colors, 'white');
      background-color: var(--#{$rd-prefix}color-primary-lighter);
    }

    @include when(between) {
      background-color: var(--#{$rd-prefix}background-color-primary);
    }

    @include when(between-hover) {
      &::before {
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        content: '';
        background-color: var(--#{$rd-prefix}background-color-primary);
      }
    }
  }

  @include e(footer) {
    @include polyfill-column-gap(4px);

    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 41px;
    border-top: 1px solid var(--#{$rd-prefix}color-divider);

    @include m(custom) {
      justify-content: flex-start;
      padding: 4px;
    }
  }

  @include e(footer-button) {
    @include overwrite-component(tag) {
      cursor: pointer;
    }
  }
}
